import {
    graphqlKoa,
    graphiqlKoa
} from 'graphql-server-koa'
import Router from 'koa-router'
import schema from '../graphql/schma'

const myrouter = new Router()
myrouter.post('/graphql', async (ctx, next) => {

        await graphqlKoa({
            schema: schema
        })(ctx, next) // 使用schema
    })
    .get('/graphql', async (ctx, next) => {
        await graphqlKoa({
            schema: schema
        })(ctx, next) // 使用schema
    })
    .get('/graphiql', async (ctx, next) => {
        await graphiqlKoa({
            endpointURL: '/graphql'
        })(ctx, next)
    })
export default myrouter
